package com.example.myandroidapp1;

import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;

import com.example.myandroidapp1.activity.AbstractBaseActivity;

public class SoundStuff extends AbstractBaseActivity implements OnClickListener, OnLongClickListener {

	// sound pool is for short clips
	private SoundPool sp;
	
	private int explosion = 0;
	
	// Media player is for songs/long music
	private MediaPlayer mp;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		View view = new View(this);
		view.setOnClickListener(this);
		view.setOnLongClickListener(this);
		setContentView(view);
		sp = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
		explosion = sp.load(this, R.raw.explosion, 1);
		mp = MediaPlayer.create(this, R.raw.beep_30);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (explosion != 0) {
			sp.play(explosion, 1, 1, 0, 0,2);
		}
	}
	
	@Override
	public boolean onLongClick(View v) {
		// TODO Auto-generated method stub
		mp.start();
		return false;
	}
}
